//
//  __theme.swift
//  Aiwei
//
//  Created by zhu xietong on 2017/10/11.
//  Copyright © 2017年 zhu xietong. All rights reserved.
//

import Foundation
import soapp
let __main_hex = "#5227BE"
let __second_hex = "#E42154"
//let __iwe_hex = "#CC1522"

let __cl_border = UIColor(shex:"#c1c1c1")
let __edge:CGFloat = 16
let __button_height:CGFloat = 36
let __darkBackHex = "#3e3a39"

extension UIImage
{
    @objc public static var goods_holder:UIImage{
        get{
            return  UIImage.image(UIColor.main_color, size: [100,100])
        }
    }
}

//class ___yigou {
//    static let hex1 = "#3C4AD7"
//    static let hex2 = "#FF8737"
//    static var top_nav:EeTopStyle{
//        get{
//            var style = EeTopStyle()
//            style.navTintColor = UIColor(shex:"#fff")
//            style.navBarBgAlpha = 1
//            style.navBarBgStyle = .color(UIColor(shex: ___yigou.hex1))
//            style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#fff"),NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18)]
//            //        style.navBarShadow = .color(UIColor(white: 0.3, alpha: 0.5))
//            style.statusBarStyle = .lightContent
//
//            style.navBarShadow = .none
//            return style
//        }
//    }
//}
//
//class ___shop {
//    static let hex1 = "#E42154"
//    static let hex2 = "#FF8737"
//    static var top_nav:EeTopStyle{
//        get{
//            var style = EeTopStyle()
//            style.navTintColor = UIColor(shex:"#fff")
//            style.navBarBgAlpha = 1
//            style.navBarBgStyle = .color(UIColor(shex: ___shop.hex1))
//            style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#fff"),NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18)]
//            //        style.navBarShadow = .color(UIColor(white: 0.3, alpha: 0.5))
//            style.statusBarStyle = .lightContent
//
//            style.navBarShadow = .none
//            return style
//        }
//    }
//}
//class ___house {
//    static let hex1 = "#1BBE74"
//    static let hex2 = "#FF8737"
//
//    static var top_nav:EeTopStyle{
//        get{
//            var style = EeTopStyle()
//            style.navTintColor = UIColor(shex:"#fff")
//            style.navBarBgAlpha = 1
//            style.navBarBgStyle = .color(UIColor(shex: ___house.hex1))
//            style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#fff"),NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18)]
//            //        style.navBarShadow = .color(UIColor(white: 0.3, alpha: 0.5))
//            style.statusBarStyle = .lightContent
//
//            style.navBarShadow = .none
//            return style
//        }
//    }
//}
//
//class ___city {
//    static let hex1 = "#3C4AD7"
//    static let hex2 = "#FF8737"
//    static var top_nav:EeTopStyle{
//        get{
//            var style = EeTopStyle()
//            style.navTintColor = UIColor(shex:"#fff")
//            style.navBarBgAlpha = 1
//            style.navBarBgStyle = .color(UIColor(shex: ___city.hex1))
//            style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#fff"),NSAttributedString.Key.font:UIFont.systemFont(ofSize: 18)]
//            //        style.navBarShadow = .color(UIColor(white: 0.3, alpha: 0.5))
//            style.statusBarStyle = .lightContent
//
//            style.navBarShadow = .none
//            return style
//        }
//    }
//}


class __theme {
    static let darkBackHex = "#3e3a39"
    static let darkCellHex = "#1a1e27"
    static let darkYellowHex = "#daab71"
    static func light()->EeTopStyle{
        var style = EeTopStyle()
        
        style.navTintColor = UIColor(shex:"#fff")
        style.statusBarStyle = .lightContent
        style.navBarBgAlpha = 1
        style.navBarBgStyle = .color(UIColor(shex:__main_hex))
        style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#fff"),NSAttributedString.Key.font:UIFont.systemFont(ofSize: 16)]
        //        style.navBarShadow = .color(UIColor(white: 0.3, alpha: 0.5))
        style.navBarShadow = .none
        UIColor.main_hex = __main_hex

        return style
    }
    
    static func white() ->EeTopStyle
    {
        var style = EeTopStyle()
        style.navTintColor = UIColor(shex:"#444")
        style.statusBarStyle = .default
        style.navBarBgAlpha = 1
        style.navBarBgStyle = .color(UIColor(shex: "#fff"))
        style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#444"),NSAttributedString.Key.font:UIFont.boldSystemFont(ofSize: 16)]
        style.navBarShadow = .color(UIColor(white: 0.6, alpha: 0.3))
        UIColor.main_hex = __main_hex

        return style
    }
    
    static func blur() ->EeTopStyle
    {
        var style = EeTopStyle()
        style.navTintColor = UIColor(shex:"#444")
        style.statusBarStyle = .default
        style.navBarBgStyle = .blur(.extraLight)
        style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#444"),NSAttributedString.Key.font:UIFont.boldSystemFont(ofSize: 16)]
        style.navBarBgAlpha = 1
        
        style.navBarShadow = .color(UIColor(white: 0.6, alpha: 0.3))
        UIColor.main_hex = __main_hex

        return style
    }
    
    static func purple() ->EeTopStyle{
        var style = EeTopStyle()
        style.navTintColor = UIColor(shex:"#fff")
        style.statusBarStyle = .lightContent
        style.navBarBgAlpha = 1
        style.navBarBgStyle = .color(UIColor(shex: __main_hex))
        style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#fff"),NSAttributedString.Key.font:UIFont.boldSystemFont(ofSize: 16)]
        style.navBarShadow = .color(.clear)
        return style
    }
    
    static func `default`()->EeTopStyle
    {
        var style = EeTopStyle()
        style.navTintColor = UIColor(shex:"#111")
        style.statusBarStyle = .default
        style.navBarBgAlpha = 1
        style.navBarBgStyle = .color(UIColor(shex: "#666"))
        style.titleTextAttributes = [NSAttributedString.Key.foregroundColor:UIColor(shex:"#444"),NSAttributedString.Key.font:UIFont.boldSystemFont(ofSize: 16)]
        style.navBarShadow = .color(UIColor(white: 0.6, alpha: 0.3))
        //        style.navBarShadow = .none
        
        
        FieldCell.padding_top = 16
        FieldCell.padding_bottom = 16
        FieldCell.padding_left = __edge
        FieldCell.padding_right = __edge - 10
        FieldCell.name_width = 70
        
        FK.indicator_more_img = "f_more_indicator"
        
        
        FieldView.holderStyle.font = UIFont.systemFont(ofSize: 13)
        FieldView.valueStyle.font = UIFont.systemFont(ofSize: 13)
        FieldView.valueStyle.color = UIColor(shex:"#111")
        
        
        UIColor.main_hex = __main_hex
        UIColor.separator_hex = "#ccca"
        UIColor.table_bg_hex = "#f7f7f7"
//        UIColor.table_bg_hex = "#EfEfEf"
        
        //        let backImageInsets = UIEdgeInsetsMake(0, 0, 0, 0)
        //        let indicatorImg = UIImage(named:"nav_f_back")?.rt_tintedImage(with: UIColor(shex:"#333"))
        //        let bck = indicatorImg?.withRenderingMode(.alwaysOriginal).withAlignmentRectInsets(backImageInsets)
        //        UINavigationBar.appearance().backIndicatorImage = bck
        //        UINavigationBar.appearance().backItem?.backBarButtonItem?.setTitlePositionAdjustment(UIOffset(horizontal: 0, vertical: 0), for: .default)
        //        UINavigationBar.appearance().backIndicatorTransitionMaskImage = bck
        
        //        let backImageInsets = UIEdgeInsetsMake(0, 0, 0, 0)
        //        let indicatorImg = UIImage(named:"nav_f_back")?.rt_tintedImage(with: UIColor(shex:"#333"))
        //        let bck = indicatorImg?.withRenderingMode(.alwaysOriginal).withAlignmentRectInsets(backImageInsets)
        

        
        UINavigationBar.appearance().backIndicatorImage = UIImage(named:"nav_back_normal_default")
        UINavigationBar.appearance().backItem?.backBarButtonItem?.setTitlePositionAdjustment(UIOffset(horizontal: -8, vertical: 0), for: .default)
        UINavigationBar.appearance().backIndicatorTransitionMaskImage = UIImage.image(.clear, size: [0.1,0.1])
        
        AppTheme.nav_back_img = UIImage(named:"nav_back_normal1")
        
        
        
        //       UIBarButtonItem.appearance().setTitleTextAttributes(<#T##attributes: [NSAttributedStringKey : Any]?##[NSAttributedStringKey : Any]?#>, for: .normal)
        UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font:UIFont.systemFont(ofSize: 14)], for: .normal)
        UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedString.Key.font:UIFont.systemFont(ofSize: 14)], for: .highlighted)

        return style
    }
    
}


extension UIFont{
    static func yahei(size:CGFloat)->UIFont{
        let font = UIFont(name: "MicrosoftYaHei", size: size.so) ?? UIFont.systemFont(ofSize: size)
        return font
    }
    
    static func uniSansThin(size:CGFloat)->UIFont{
        let font = UIFont(name: "UniSansThinCAPS", size: size.so) ?? UIFont.systemFont(ofSize: size)
        return font
    }
    
    static func simSun(size:CGFloat)->UIFont{
        //        let font = UIFont(name: "SimSun", size: size.so) ?? UIFont.systemFont(ofSize: size)
        let font = UIFont.systemFont(ofSize: size);
        return font
    }
    
    static func sourceSansPro(size:CGFloat)->UIFont{
        //        let font = UIFont(name: "SourceSansPro-BoldIt", size: size.so) ?? UIFont.systemFont(ofSize: size)
        let font = UIFont(name: "MyriadPro-Regular", size:size) ?? UIFont.systemFont(ofSize: size)
        return font
        
    }
    
    
}

extension LabelStyle{
    public func _yahei(size:CGFloat) -> LabelStyle {
        let font = UIFont.yahei(size: size)
        return self.font(font: font)
    }
    public var yh_font10:LabelStyle  {return self._yahei(size: 10)}
    public var yh_font11:LabelStyle  {return self._yahei(size: 11)}
    public var yh_font12:LabelStyle  {return self._yahei(size: 12)}
    public var yh_font13:LabelStyle  {return self._yahei(size: 13)}
    public var yh_font14:LabelStyle  {return self._yahei(size: 14)}
    public var yh_font15:LabelStyle  {return self._yahei(size: 15)}
    public var yh_font16:LabelStyle  {return self._yahei(size: 16)}
    public var yh_font17:LabelStyle  {return self._yahei(size: 17)}
    public var yh_font18:LabelStyle  {return self._yahei(size: 18)}
    public var yh_font19:LabelStyle  {return self._yahei(size: 19)}
    public var yh_font20:LabelStyle  {return self._yahei(size: 20)}
    public var yh_font21:LabelStyle  {return self._yahei(size: 21)}
    public var yh_font22:LabelStyle  {return self._yahei(size: 22)}
    
    public func _uniSansThin(size:CGFloat) -> LabelStyle {
        let font = UIFont.uniSansThin(size: size)
        return self.font(font: font)
    }
    public var uni_font10:LabelStyle  {return self._uniSansThin(size: 10)}
    public var uni_font11:LabelStyle  {return self._uniSansThin(size: 11)}
    public var uni_font12:LabelStyle  {return self._uniSansThin(size: 12)}
    public var uni_font13:LabelStyle  {return self._uniSansThin(size: 13)}
    public var uni_font14:LabelStyle  {return self._uniSansThin(size: 14)}
    public var uni_font15:LabelStyle  {return self._uniSansThin(size: 15)}
    public var uni_font16:LabelStyle  {return self._uniSansThin(size: 16)}
    public var uni_font17:LabelStyle  {return self._uniSansThin(size: 17)}
    public var uni_font18:LabelStyle  {return self._uniSansThin(size: 18)}
    public var uni_font19:LabelStyle  {return self._uniSansThin(size: 19)}
    public var uni_font20:LabelStyle  {return self._uniSansThin(size: 20)}
    public var uni_font21:LabelStyle  {return self._uniSansThin(size: 21)}
    public var uni_font22:LabelStyle  {return self._uniSansThin(size: 22)}
    
    public func _simSun(size:CGFloat) -> LabelStyle {
        let font = UIFont.simSun(size: size)
        return self.font(font: font)
    }
    public var sim_font10:LabelStyle  {return self._simSun(size: 10)}
    public var sim_font11:LabelStyle  {return self._simSun(size: 11)}
    public var sim_font12:LabelStyle  {return self._simSun(size: 12)}
    public var sim_font13:LabelStyle  {return self._simSun(size: 13)}
    public var font15:LabelStyle  {return self._simSun(size: 14)}
    public var sim_font15:LabelStyle  {return self._simSun(size: 15)}
    public var sim_font16:LabelStyle  {return self._simSun(size: 16)}
    public var sim_font17:LabelStyle  {return self._simSun(size: 17)}
    public var sim_font18:LabelStyle  {return self._simSun(size: 18)}
    public var sim_font19:LabelStyle  {return self._simSun(size: 19)}
    public var sim_font20:LabelStyle  {return self._simSun(size: 20)}
    public var sim_font21:LabelStyle  {return self._simSun(size: 21)}
    public var sim_font22:LabelStyle  {return self._simSun(size: 22)}
    
    
    
}

extension StringStyle{
    
    public func sim_font(_ size:CGFloat)->StringStyle{
        
        return self.font(font: UIFont.simSun(size: size))
    }
    public func uni_sans_font(_ size:CGFloat)->StringStyle{
        return self.font(font: UIFont.uniSansThin(size: size))
    }
    
}

